class UsersController < ApplicationController
  before_action :set_user, only: [:follows, :topics, :paid]

  def follows
    @title = @user.name
    @topics = @user.follow_topics
    if @topics
      @articles = Article.where( topic_id: @topics.each{|topic|topic.id} ).page get_page
    else
    end
    render :home
  end

  def paid
    @title = "#{@user.name}已购买的话题"
    @topics = @user.paid_topics.page get_page
    render :home
  end

  def topics
    @title = "#{@user.name}的主题"
    @topics = @user.topics.page get_page
    render :home
  end

  protected

  def set_user
    @user = User.find(params[:id])
  end

end
